package com.aube.mis.run;

import java.io.File;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JettyRunner {
	
    private static final Logger log = LoggerFactory.getLogger(JettyRunner.class);
    
	private static int PORT = 8188;

	public static void main(String[] args) {
		initServer();
	}

	/**
	 * 初始化web容器配置
	 * 
	 * @param server
	 */
	private static void initServer() {
		try {
			log.info("开始初始化Jetty容器");
			Server server = new Server(PORT);
			WebAppContext webapp = new WebAppContext();
			webapp.setContextPath("/mis");
			webapp.setWar(Thread.currentThread().getContextClassLoader().getResource("META-INF/webapp/").toString());
			webapp.setTempDirectory(new File("/home/jetty-temp"));
			server.setHandler(webapp);
			server.start();
			server.join();
		} catch (Exception e) {
			log.error("初始化web容器配置异常", e);
			e.printStackTrace();
		}
	}
}
